package com.xunwulian.cmpp.util;

import com.google.gson.Gson;
import com.xunwulian.base.constant.SmsStatus;
import com.xunwulian.base.constant.SmsType;
import com.xunwulian.base.entity.CardInfoEntity;
import com.xunwulian.base.entity.SmsPocessorEntity;
import com.xunwulian.cmpp.pdu.Deliver;
import com.xunwulian.cmpp.pdu.Submit;
import com.xunwulian.cmpp.sms.ByteBuffer;
import com.xunwulian.cmpp.sms.PDUException;
import com.xunwulian.cmpp.sms.ShortMessage;

/**
 * Created by liyankai on 2016/8/19.
 */
public class TestUtil {

    private static Gson gson = new Gson();

    public static Deliver buildDeliver() {

        Deliver entity = new Deliver();

        entity.setDstId("deliver_destId");
        entity.setIsReport((byte) 0);
        entity.setSrcTermId("deliver");
        entity.setMsgId("msgId".getBytes());
        entity.setServiceId("serviceId");

        ShortMessage sm = new ShortMessage();
        ByteBuffer data = new ByteBuffer();
        data.setBuffer("shortmessage".getBytes());
        try {
            sm.setData(data);
        } catch (PDUException e) {
            e.printStackTrace();
        }
        entity.setSm(sm);
        entity.setLinkId("linkId");

        System.out.println("Deliver:" + gson.toJson(entity, Deliver.class));
        return entity;
    }

    public static Submit buildSubmit() {
        Submit entity = new Submit(new String[]{"submit_DestTermId"}, 100,
                "content", "serviceId", "submit_SrcId", ""
        );

        System.out.println("Submit:" + gson.toJson(entity, Submit.class));
        return entity;
    }


    /*
      * bean
     */
    public static CardInfoEntity buildCardInfo() {

        CardInfoEntity entity = new CardInfoEntity();
        entity.setMsisdn("1234567890");
        return entity;
    }

    public static SmsPocessorEntity buildSmsPocessor() {
        SmsPocessorEntity entity = new SmsPocessorEntity("1234567890", SmsType.SEND.type, "test", "test", "001001",
                SmsStatus.INIT.type, 1, "appId");
        return entity;
    }
}
